package com.example.sys.controller;

import com.example.sys.entity.dto.LoginUserDto;
import com.example.sys.entity.vo.LoginUserInfoVo;
import com.example.sys.service.LoginService;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
@RequestMapping("login")
public class LoginController {
    @Resource
    private LoginService loginService;

    /**
     * 根据手机号登录
     * @return
     */
    @PostMapping("/iphoneNo")
    public LoginUserInfoVo loginByIphoneNoAndPwd(@RequestBody @Validated(LoginUserDto.iphoneLogin.class) LoginUserDto loginUserDto){
        LoginUserInfoVo vo = loginService.loginByIphoneNoAndPwd(loginUserDto);
        return vo;
    }

    /**
     * 根据邮箱登录
     * @return
     */
    @PostMapping("/email")
    public LoginUserInfoVo loginByEmailAndPwd(@RequestBody @Validated(LoginUserDto.emailLogin.class) LoginUserDto loginUserDto){
        LoginUserInfoVo vo = loginService.loginByEmailAndPwd(loginUserDto);
        return vo;
    }
}
